package com.project.customview

import com.project.customview.algorithm.Card
import org.junit.Test

import org.junit.Assert.*
import android.R.array



/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
class ExampleUnitTest {
    @Test
    fun addition_isCorrect() {
        assertEquals(4, 2 + 2)
    }

    @Test
    fun testCards() {

        val array = arrayOf<Card>(Card(3, 2),
                Card(2, 9), Card(1, 7), Card(3, 5), Card(4, 3))
        bubleSort1(array);
        for (item in array){
            System.out.println(item.toString())
        }

    }

    fun bubbleSort(array:Array<Card>){
        for (i in array.size - 1 downTo 1) {
            var flag = true
            for (j in 0 until i) {
                if (array[j] > array[j + 1]) {
                    val temp = array[j]
                    array[j] = array[j + 1]
                    array[j + 1] = temp
                    flag = false
                }
            }
            if (flag) {
                break
            }
        }
    }
    fun bubleSort1(array: Array<Card>){
        for (i in array.size-1 downTo 1){
            var flag = true;
            for (j in 0 until i){
                if (array[j]>array[j+1]){
                    var temp = array[j]
                    array[j] = array[j+1]
                    array[j+1] = temp
                    flag = false
                }
            }
            if (flag){
                break
            }
        }
    }



}
